<!--机构端-招聘人才-面试邀请记录  -->
<template>
  <view class="container">
    <!-- 顶部选项卡 -->
    <u-tabs :list="tabList" :current="currentTab" @change="changeTab"></u-tabs>
    
    <!-- 简历列表 -->
    <view v-if="resumeList.length > 0">
      <view v-for="(item, index) in filteredResumes" :key="index" class="resume-item">
        <view class="resume-header">
          <text class="user-name">岗位：{{ item.tdyq_gw_name }}</text>
          <text class="position">投递者：{{ resume_name[index] }}</text>
        </view>
        <view class="resume-info" >
          <text>面试时间：{{ item.tdyq_msdate }}</text>
					<text @click="selectResume(index)">查看简历></text>
        </view>
				<view class="resume-info">
				  <text>面试地址：{{ item.tdyq_msaddr}}</text>
				</view>
				<view class="resume-info">
				  <text>联系人：{{ item.tdyq_msusername }} TEL:{{item.tdyq_msphoneno}}</text>
				</view>
				<view class="resume-info">
				  <text>微信号：{{ item.tdyq_mswxid}}</text>
				</view>
        <view class="resume-footer">
          <!-- <text class="time">状态：{{ item.cy_isread }}</text>					 -->
          <text class="status" :class="{'unviewed': item.cy_isread === 0, 
                                'viewed': item.cy_isread === 1,
                                'interview': item.cy_isread === '已邀面试',
                                'rejected': item.cy_isread === '不合适'}">状态：{{ item.cy_isread == 0 ? '未查看' : '已查看' }}</text>
        </view>
      </view>
    </view>
    
    <!-- 空状态 -->
    <u-empty v-else mode="list" icon="http://cdn.uviewui.com/uview/empty/list.png"></u-empty>
  </view>
</template>

<script>
export default {
  data() {
    return {
      currentTab: 0,
      tabList: [
        { name: '全部' },
        { name: '未查看' },
        { name: '已查看' }
      ],
      resumeList: [
        {
          userName: '用户姓名',
          position: '康养师',
          age: '88',
          education: '大专',
          experience: '6',
          certificate: 'XXXX等级证书',
          deliveryTime: '2025-05-23',
          status: '未查看'
        },
        {
          userName: '用户姓名',
          position: '康养师',
          age: '88',
          education: '大专',
          experience: '6',
          certificate: 'XXXX等级证书',
          deliveryTime: '2025-05-23',
          status: '已查看'
        },
        {
          userName: '用户姓名',
          position: '康养师',
          age: '88',
          education: '大专',
          experience: '6',
          certificate: 'XXXX等级证书',
          deliveryTime: '2025-05-23',
          status: '已邀面试'
        },
        {
          userName: '用户姓名',
          position: '康养师',
          age: '88',
          education: '大专',
          experience: '6',
          certificate: 'XXXX等级证书',
          deliveryTime: '2025-05-23',
          status: '不合适'
        }
      ],
			resume_name:[],
    }
  },
	onShow() {
		this.$u.api.queryjgyqmslist({
			"usercode":uni.getStorageSync('usercode'),  ///#机构的code
		}).then(res => {
			console.log('邀请列表：', res);
			this.resumeList = res.data.base_info
			// 根据读回来的邀请，获取个人简历
			for(var i=0; i<this.resumeList.length; i++) {
				this.$u.api.queryjlfull({
					usercode : this.resumeList[i].user_code
				}).then(res => {
					this.resume_name.push(res.data.base_info.base.jlbi_name)
					
				})
			}	
			console.log('增加了个人简历：', this.resume_name)
			
		})
		
	},
  computed: {
    filteredResumes() {
      if (this.currentTab === 0) return this.resumeList
      if (this.currentTab === 1) return this.resumeList.filter(item => item.cy_isread === '未查看')
      if (this.currentTab === 2) return this.resumeList.filter(item => item.cy_isread === '已查看')
      return this.resumeList
    }
  },
  methods: {
    changeTab(index) {
      this.currentTab = index
    },
		// 查看个人简历
		selectResume(id) {
			uni.navigateTo({
				url: `/pages/Institution/invite/online-resume?usercode=${this.resumeList[id].user_code}`
			});				
		}
  }
}
</script>

<style lang="scss" scoped>
.container {
  padding: 20rpx;
}

.resume-item {
  padding: 30rpx;
  margin-bottom: 20rpx;
  background-color: #fff;
  border-radius: 10rpx;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}

.resume-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15rpx;
  
  .user-name {
    font-size: 32rpx;
    font-weight: bold;
  }
  
  .position {
    font-size: 28rpx;
    color: #666;
  }
}

.resume-info {
	display: flex;
	justify-content:space-between;
  font-size: 26rpx;
  color: #888;
  // margin-bottom: 20rpx;
}

.resume-footer {
  display: flex;
  justify-content: space-between;
  font-size: 24rpx;
  color: #999;
  
  .status {
    &.unviewed {
      color: #f56c6c;
    }
    &.viewed {
      color: #409eff;
    }
    &.interview {
      color: #67c23a;
    }
    &.rejected {
      color: #909399;
    }
  }
}
</style>